//
//  LGHomeViewController.swift
//  微博框架
//
//  Created by ming on 16/10/3.
//  Copyright © 2016年 ming. All rights reserved.
//

import UIKit

class LGHomeViewController: LGBasiViewController {
    
    lazy var  statuList = LGStatusList()
 let  ID = "cellID"
    //数据数组
   lazy var dataArray = [String]()
    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

@objc func frenides(){
       navigationController?.pushViewController(LGTestViewController(), animated: true)
    }

}


extension LGHomeViewController{
    
       func setBarButton(){
        let letfButton = UIButton.cz_textButton("好友", fontSize: 14, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        letfButton?.addTarget(self, action: #selector(frenides), for: .touchUpInside)
        navItem.leftBarButtonItem = UIBarButtonItem(customView: letfButton!)
    
    
    
    }
  
}


extension LGHomeViewController{
    
 
    
    
    override func loadData() {
            self.statuList.isFull = self.isRefreshing
        
        
       
            
        self.statuList.loadData(completion: { (isSuccess,isFull) in
    
        //加载数据成功回调
             self.isRefreshing = false
         self.tableView?.reloadData()
        self.refresh.endRefreshing()
        self.tabBarController?.tabBar.items?[0].badgeValue = nil
            
       })
        

        

    }
    
    override func setTableView() {
        
       
         super.setTableView()
        
        tableView?.register(UITableViewCell.self, forCellReuseIdentifier: ID)
        setBarButton()
        print(tableView?.contentInset)
       
    }
    
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return  statuList.dataArray.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: ID)
        cell?.textLabel?.text = statuList.dataArray[indexPath.row].text
        
        return cell!
        
        
    }
    
    
}
